//
//  XDHomeItemView.m
//  XDEducation
//
//  Created by apple on 2017/4/8.
//  Copyright © 2017年 apple. All rights reserved.
//

#import "XDHomeItemView.h"

@interface XDHomeItemView ()

/** image */
@property(nonatomic,strong) UIImageView *imageView;

/** title */
@property(nonatomic,strong) UILabel *label;

@end

@implementation XDHomeItemView

-(instancetype)initWithFrame:(CGRect)frame andTitle:(NSString *)title imageName:(NSString *)imageName{

    if (self = [super initWithFrame:frame]) {
        
        
        _imageView = [[UIImageView alloc]init];
        _imageView.frame = CGRectMake(0, 0, 24, 25);
        _imageView.center = CGPointMake(frame.size.width/2, frame.size.width/2 );
        _imageView.image = [UIImage imageNamed:imageName];
        [self addSubview:_imageView];
        
        _label = [[UILabel alloc]init];
        _label.frame = CGRectMake(0, frame.size.height - 20, frame.size.width, 20);
        _label.text = title;
        _label.textAlignment = NSTextAlignmentCenter;
        _label.textColor = UIColorFromRGB(0x4c4c4c);
        _label.font = [UIFont systemFontOfSize:14];
        [self addSubview:_label];
        
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickedEvent)];
        [self addGestureRecognizer:tap];
    }
    
    return self;
}

-(void)clickedEvent{

    if (self.itemClickedBlock) {
        self.itemClickedBlock();
    }
}

@end
